package com.github.pig.admin.service.sys.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.github.pig.admin.mapper.sys.PaymentRecordMapper;
import com.github.pig.admin.model.entity.PaymentRecord;
import com.github.pig.admin.model.entity.PaymentRecordPrint;
import com.github.pig.admin.model.entity.PaymentRecordPrintWhere;
import com.github.pig.admin.model.managerfee.FeeStatisticsBean;
import com.github.pig.admin.model.managerfee.FeeStatisticsWhere;
import com.github.pig.admin.service.sys.PaymentRecordService;
import com.github.pig.admin.util.AjaxJson;
import com.github.pig.common.constant.CommonConstant;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 缴费记录表 服务实现类
 * </p>
 *
 * @author xiaosa
 * @since 2018-07-23
 */
@Service
public class PaymentRecordServiceImpl extends ServiceImpl<PaymentRecordMapper, PaymentRecord> implements PaymentRecordService {

    @Autowired
    private PaymentRecordMapper mapper;

    @Override
    public Page<PaymentRecord> indexPage(Page<PaymentRecord> page,PaymentRecord paymentRecord) {
        List<PaymentRecord> list = mapper.selectPages(page,paymentRecord);

        return page.setRecords(list);
    }

    @Override
    public AjaxJson queryById(String id) {
        AjaxJson ajaxJson = new AjaxJson();
        if (StringUtils.isNotBlank(id)){
            ajaxJson.setObj(mapper.queryById(id));
            ajaxJson.setSuccess(true);
        }else {
            ajaxJson.setSuccess(false);
        }

        return ajaxJson;
    }

    @Override
    public Page indexStatisticsPage(Page page, FeeStatisticsWhere where) {
        List result = mapper.selectPayStatisticsPage(page,where);
        page.setRecords(result);
        return page;
    }

    @Override
    public List<PaymentRecordPrint> printFeePage(PaymentRecordPrintWhere paymentRecord) {
        return mapper.printFeePage(paymentRecord);
    }
}
